//
//  AXFCellSelectedTableViewController.m
//  AIXF
//
//  Created by Macx on 2017/7/10.
//  Copyright © 2017年 Macx. All rights reserved.
//

#import "AXFCellSelectedTableViewController.h"
#import "AXFSelectCellHeadView.h"
#import "UIView+WP.h"
#import "AXFSelecteCellCarView.h"
#import <Masonry.h>
#import "AXFShoppingCarViewController.h"
#import "AXFGoodsViewController.h"
#import "AXFAccountManager.h"
@interface AXFCellSelectedTableViewController ()

@end

@implementation AXFCellSelectedTableViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    
    
    
}

- (void)setModel:(AXFHomeFirstSellModel *)model
{
    _model = model;
    
    UITableView *tableView = [[UITableView alloc] initWithFrame:self.view.bounds style:UITableViewStylePlain];
    
    [self.view addSubview:tableView];
    
    AXFSelectCellHeadView *headView = [[AXFSelectCellHeadView alloc] initWithFrame:CGRectMake(0, 0, self.view.bounds.size.width, self.view.bounds.size.height + 100)];
    
    headView.model = model;
    
    tableView.tableHeaderView = headView;
    
    UIImageView *imageView = [[UIImageView alloc] init];
    
    tableView.tableFooterView = imageView;
    
    UIImage *image = [UIImage imageNamed:@"aaaa"];
    
    imageView.image = image;
    
    imageView.width = self.view.bounds.size.width;
    
    imageView.height = image.size.height / image.size.width * self.view.bounds.size.width;
    
    AXFSelecteCellCarView *carView = [[AXFSelecteCellCarView alloc] init];
    carView.model = model;
    
    [self.view addSubview:carView];
    
    [carView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.bottom.right.equalTo(self.view);
        make.height.offset(60 );
    }];
    
    for (UIView *subView in carView.subviews)
    {
        if ([subView.restorationIdentifier isEqualToString:@"100"])
        {
            UIButton *carBtn = (UIButton *)subView;
            
            [carBtn addTarget:self action:@selector(clickCarBtn) forControlEvents:UIControlEventTouchUpInside];
        }
    }
    
}

- (void)clickCarBtn
{

    [self presentViewController:[AXFGoodsViewController new] animated:YES completion:nil];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    
}


@end
